package com.jpemartin.jgt;
import java.awt.Rectangle;

/** move vertically following a sine wave.
 * @see MoveHorizontalWave
 * 
 * @author jpmartin
 */
public class MoveVerticalWave implements MoveControl {

   // angular velocity
   int _da;
   // amplitude
   int _dy;
   
   // previous Y delta
   int _ody = 0;
   int _angle = 0;
   
   public MoveVerticalWave(int amplitude, int angularVelocity) {
      _da = angularVelocity;
      _dy = amplitude;
      _angle = 0;
   }
   
   public void move(Rectangle moved) {
      _angle += _da;
      int change = (int)(Math.sin((double)(_angle)/180.0*Math.PI)*_dy);
      moved.y = moved.y - _ody + change;
      _ody = change;
   }

}
